<!DOCTYPE html>
<html>
#{include file="header.html"}#
<body class="gray-bg">
<div class="wrapper wrapper-content animated fadeInRight">
  <div class="row">
    <div class="col-sm-12">
      <div class="ibox float-e-margins">
        <div class="ibox-title">
          <h5>品牌添加</h5>
          <div class="ibox-tools">
            <button type="button" class="btn btn-xs btn-primary btn-back-reply"><i class='fa fa-reply'></i> 返回</button>
          </div>
        </div>
        <div class="ibox-content">
          <form class="form-horizontal" method="post" action="#{$smarty.const.ACT}#/goods/GoodsBrand/goods_brand_add/"  enctype="multipart/form-data">
            <div class="form-group">
              <label class="col-sm-2 control-label">品牌名称：</label>
              <div class="col-sm-8">
                <input name="brand_name" class="form-control" type="text" placeholder="请输入品牌名称" required/>
              </div>
            </div>
				<div class="form-group">
					<label class="col-sm-2 control-label">品牌首字母：</label>
					<div class="col-sm-8">
					<input name="brand_initial" class="form-control" type="text" placeholder="请输入品牌首字母" required/>
					</div>
				</div>
			  
			  <div class="form-group">
					<label class="col-sm-2 control-label">品牌图片：</label>
					<div class="col-sm-8">
						<div id="drop_area"></div>
						<input type="text" id="brand_pic" name="brand_pic" class="form-control">
					</div>
				</div>
            <div class="form-group">
              <label class="col-sm-2 control-label">品牌排序：</label>
              <div class="col-sm-8">
                <input name="sort" class="form-control" type="digits" value="#{$one.sort}#" placeholder="品牌排序"/>
              </div>
            </div>
            <div class="form-group">
              <label class="col-sm-2 control-label">是否推荐：</label>
              <div class="col-sm-8">
                <div class="checkbox i-checks">
                  <input type="checkbox" name="brand_recommend" value="1" checked/>
                </div>
              </div>
            </div>

            <div class="form-group">
              <div class="col-sm-offset-2 col-sm-8">
                <button class="btn btn-info" type="submit">保存数据</button>
              </div>
            </div>
          </form>
        </div>
      </div>
    </div>
  </div>
</div>
<!-- Prettyfile --> 
<script src="#{$smarty.const.APP}#/View/template/js/upload.js"></script> 

<script>
$(document).ready(function () {
	$('.i-checks').iCheck({
		checkboxClass: 'icheckbox_square-green',
		radioClass: 'iradio_square-green',
	});
});
	
	
</script>
	
<script type="text/javascript">
var dragImgUpload = new DragImgUpload("#drop_area",{
	callback:function (files) {
		//回调函数，可以传递给后台等等
		var file = files[0];
		var formData = new FormData();
		formData.append('filepath',files[0]);
		//Ajax调用处理
		$.ajax({
			type: "POST",
			url: "/index.php/Upload/upload_images/",
			data:formData,
			dataType:"json", //声明成功使用json数据类型回调
			//如果传递的是FormData数据类型，那么下来的三个参数是必须的，否则会报错
			cache:false,  //默认是true，但是一般不做缓存
			processData:false, //用于对data参数进行序列化处理，这里必须false；如果是true，就会将FormData转换为String类型
			contentType:false,
			success: function(data){
				$("#brand_pic").val(data.spath);
			}
		});   
		console.log(file.name);
	}
})
</script>
</body>
</html>
